package com.ruoyi.project.purchase.contract.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.purchase.contract.domain.Htcghtbcxy;
import com.ruoyi.project.purchase.contract.service.IHtcghtbcxyService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 采购合同Controller
 * 
 * @author frank
 * @date 2024-08-20
 */
@RestController
@RequestMapping("/purchase/contract/htcghtbcxy")
public class HtcghtbcxyController extends BaseController
{
    @Autowired
    private IHtcghtbcxyService htcghtbcxyService;

    /**
     * 查询采购合同列表
     */
    @PreAuthorize("@ss.hasPermi('purchase/contract:htcghtbcxy:list')")
    @GetMapping("/list")
    public TableDataInfo list(Htcghtbcxy htcghtbcxy)
    {
        startPage();
        List<Htcghtbcxy> list = htcghtbcxyService.selectHtcghtbcxyList(htcghtbcxy);
        return getDataTable(list);
    }

    /**
     * 导出采购合同列表
     */
    @PreAuthorize("@ss.hasPermi('purchase/contract:htcghtbcxy:export')")
    @Log(title = "采购合同", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Htcghtbcxy htcghtbcxy)
    {
        List<Htcghtbcxy> list = htcghtbcxyService.selectHtcghtbcxyList(htcghtbcxy);
        ExcelUtil<Htcghtbcxy> util = new ExcelUtil<Htcghtbcxy>(Htcghtbcxy.class);
        util.exportExcel(response, list, "采购合同数据");
    }

    /**
     * 获取采购合同详细信息
     */
    @PreAuthorize("@ss.hasPermi('purchase/contract:htcghtbcxy:query')")
    @GetMapping(value = "/{htCghtbcxyoid}")
    public AjaxResult getInfo(@PathVariable("htCghtbcxyoid") String htCghtbcxyoid)
    {
        return success(htcghtbcxyService.selectHtcghtbcxyByHtCghtbcxyoid(htCghtbcxyoid));
    }

    /**
     * 新增采购合同
     */
    @PreAuthorize("@ss.hasPermi('purchase/contract:htcghtbcxy:add')")
    @Log(title = "采购合同", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Htcghtbcxy htcghtbcxy)
    {
        return toAjax(htcghtbcxyService.insertHtcghtbcxy(htcghtbcxy));
    }

    /**
     * 修改采购合同
     */
    @PreAuthorize("@ss.hasPermi('purchase/contract:htcghtbcxy:edit')")
    @Log(title = "采购合同", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Htcghtbcxy htcghtbcxy)
    {
        return toAjax(htcghtbcxyService.updateHtcghtbcxy(htcghtbcxy));
    }

    /**
     * 删除采购合同
     */
    @PreAuthorize("@ss.hasPermi('purchase/contract:htcghtbcxy:remove')")
    @Log(title = "采购合同", businessType = BusinessType.DELETE)
	@DeleteMapping("/{htCghtbcxyoids}")
    public AjaxResult remove(@PathVariable String[] htCghtbcxyoids)
    {
        return toAjax(htcghtbcxyService.deleteHtcghtbcxyByHtCghtbcxyoids(htCghtbcxyoids));
    }
}
